import json, sys, array
import datetime

if len(sys.argv) < 2:
    print "enter json file"
    sys.exit(0)
    
f = open(sys.argv[1]);
players = json.loads(f.read())

levelsQuitOn = array.array('I')
levelsQuitOnToggle = array.array('I')
levelsQuitOnHold = array.array('I')
levelsQuitOnContext = array.array('I')
levelsQuitOnText = array.array('I')


for player in players:
    
    levels = player['levels']
    lastNum = -1
    
    if len(levels) > 0:
        lastLevel = levels[-1]
        lastNum = lastLevel['qid']
        
        lvlDetail = lastLevel['q_detail']
        
        while len(levelsQuitOn) <= lastNum:
            levelsQuitOn.append(0)
            levelsQuitOnToggle.append(0)
            levelsQuitOnHold.append(0)
            levelsQuitOnContext.append(0)
            levelsQuitOnText.append(0)
    
    if lastNum <= 20 and lastNum >= 0:
        levelsQuitOn[lastNum] += 1
        
        detailOpts = lvlDetail.split(",")
        
        for str in detailOpts:
            subDetail = str.split(":")
            
            if ( subDetail[0] == "{\"Context Tutorials\"" or subDetail[0] == "\"Context Tutorials\"" ):
                if (subDetail[1] == "true" or subDetail[1] == "true}" ):
                    levelsQuitOnContext[lastNum] += 1
                else:
                    levelsQuitOnText[lastNum] += 1
            
            if ( subDetail[0] == "{\"Toggle Shift\"" or subDetail[0] == "\"Toggle Shift\"" ):
                if (subDetail[1] == "true" == "true}"):
                    levelsQuitOnToggle[lastNum] += 1
                else:
                    levelsQuitOnHold[lastNum] += 1
        

for i in range(1,21):
    print "%d,%d" % (i,levelsQuitOn[i]) #,levelsQuitOnToggle[i],levelsQuitOnHold[i],levelsQuitOnContext[i],levelsQuitOnText[i])